package com.smh.demo1.a03;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * @author shiminghui
 * @date 2025/4/10 18:02
 * @description: TODO
 */
@Component
public class LifeCycleBean {

    private final static Logger log = LoggerFactory.getLogger(LifeCycleBean.class);

    public LifeCycleBean() {
        log.info("LifeCycleBean create");
    }

    @Autowired
    private void autoWired(@Value("${test.value}") String value) {
        log.info("LifeCycleBean autowired,value:{}", value);
    }

    @PostConstruct // 初始化后执行
    public void init() {
        log.info("LifeCycleBean init finish");
    }

    @PreDestroy // 销毁前执行
    public void destroy() {
        log.info("LifeCycleBean destroy will");
    }

}
